import React, { useEffect } from 'react'
import SonSub from './SonSub'
import PubSub from 'pubsub-js'

export default function FatherSub() {
    useEffect(()=> {
        let Id01 = PubSub.subscribe("法外狂徒张三", (msg, data) => {
            console.log("father Sub msg", msg);
            console.log("father Sub data", data); 
            
        })
        return () => {
            // 组件将要卸载阶段
            PubSub.unsubscribe(Id01) // 取消订阅
        }
    }, [])
  return (
    <div>
      <h3>FatherSub</h3>
      <SonSub/>
    </div>
  )
}
